import asyncio

import requests as requests
from pyppeteer import launch


def main():


    all_brands = requests.get('https://www.dongchedi.com/motor/pc/car/brand/all_brand').json()
    brands =  all_brands['data']['brand']
    brands_alllll = set()
    for i, brand in enumerate(brands):
        # print(f'brand,第{i}个值:{brand}')
        brand_id = brand['info']
        brand_id = brand_id.get('brand_id', None)  # 如果'brand_id'不存在，返回None
        # print(f'brand_id的值:{brand_id}')
        if brand_id is not None:
            brands_alllll.add(brand_id)

    print(f'brands_alllll:{brands_alllll}')



    for i, brand_item in enumerate(brands_alllll):
        allseries_ids = requests.get(
            f'https://www.dongchedi.com/motor/pc/car/brand/get_brand_series_list?aid=1839&app_name=auto_web_pc&brand_id={brand_item}&no_sales=0&show_historical_series=1&category_group_optimize=true').json()
        category_list = allseries_ids['data']['category_list']
        my_set = set()
        for i, category in enumerate(category_list):
            # print(f'第{i}个值:{category}')
            series_id_list = category['series_id_list']
            print(f'第{i}个值:{series_id_list}')
            if series_id_list is not None:
                for series_id in series_id_list:
                    my_set.add(series_id)
        # print(category_list)
        print(f'my_set:{my_set}')




if __name__ == '__main__':
    main()
